package com.inossem.utils.chart;

import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.IAxisValueFormatter;

/**
 * Created by leij on 2017/12/21.
 */

public class ChartXAxisValueFormatter implements IAxisValueFormatter {

    private ChartBean mChartBean;

    public ChartXAxisValueFormatter(ChartBean chartBean) {
        mChartBean = chartBean;
    }

    @Override
    public String getFormattedValue(float value, AxisBase axis) {
        int index = (int) value;
        if (index >= mChartBean.getX_axis_list().size() || index < 0) {
            return value + "";
        } else {
            return mChartBean.getX_axis_list().get(index).getXAxisName();
        }
    }
}
